#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int getSum(int a, int b) {
        int ret = 0;
        for (int i = 0; i < 32; i++)
        {
            if ((a & (1 << i)) & (b & (1 << i)))
                ret | (1 << i + 1);
            else
            {
                if (((a & (1 << i)) | (b & (1 << i))) & (ret & (1 << i)))
                {
                    ret | (1 << i + 1);
                    ret & (~(1 << i));
                }
                else if ((a & (1 << i)) | (b & (1 << i)))
                {
                    ret | (1 << i);
                }
            }
        }
        return ret;
    }
};

class Solution {
public:
    int getSum(int a, int b) {
        int c = a ^ b;
        int d = (a & b) << 1;
        while (d)
        {
            a = c ^ d;
            b = (c & d) << 1;
            c = a;
            d = b;
        }
        return c;
    }
};

int main()
{
    Solution s;
    s.getSum(1, 2);

    return 0;
}